#pragma warning(disable:4786)
#include <vector>
#include <map>
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

class Vehicle {
public:
	virtual double weight() const = 0;
	virtual void start() = 0;
	virtual Vehicle* copy() const = 0;
};

class RoadVehicle: public Vehicle 
{
public:
	double weight() const { cout << "weight RoadVehicle" << endl;  return 0.0; }
	void start()
	{
		cout << "start RoadVehicle" << endl;
	}
	Vehicle* copy() const
	{
		return new RoadVehicle(*this);
	}
};
class AutoVehicle: public Vehicle 
{
public:
	double weight() const { cout << "weight AutoVehicle" << endl; }
	void start()
	{
		cout << "start AutoVehicle" << endl;
	}
	Vehicle* copy() const
	{
		return new AutoVehicle(*this);
	}
};
class Aircraft: public Vehicle 
{
public:
	double weight() const { cout << "weight Aircraft" << endl; }
	void start()
	{
		cout << "start Aircraft" << endl;
	}
	Vehicle* copy() const
	{
		return new Aircraft(*this);
	}
};
class Helicopter: public Vehicle 
{
public:
	double weight() const { cout << "weight Helicopter" << endl; }
	void start()
	{
		cout << "start Helicopter" << endl;
	}
	Vehicle* copy() const
	{
		return new Helicopter(*this);
	}
};


class VehicleSurrogate {
public:
	VehicleSurrogate();
	VehicleSurrogate(const Vehicle&);
	~VehicleSurrogate();
	VehicleSurrogate(const VehicleSurrogate& );
	VehicleSurrogate& operator=(const VehicleSurrogate&);
	double weight() const
	{
		return	vp->weight();
	}
	void start()
	{
		vp->start();
	}
private:
	Vehicle* vp;
};

VehicleSurrogate::VehicleSurrogate(): vp(0) { }
VehicleSurrogate::VehicleSurrogate(const Vehicle& v):
vp(v.copy()) { }
VehicleSurrogate::~VehicleSurrogate()
{
	delete vp;
}

VehicleSurrogate::VehicleSurrogate
(const VehicleSurrogate& v):
vp(v.vp?v.vp->copy():0) {}

VehicleSurrogate& VehicleSurrogate::operator =(const VehicleSurrogate& v)
{
	if (this != &v)
	{
		delete vp;
		vp = (v.vp ? v.vp->copy() : 0);
	}
	return *this;
}

void main()
{
	RoadVehicle v;
	VehicleSurrogate parking[10];
	int i = 0;
	parking[i++] = v;
	parking[0].start();
	parking[0].weight();
}

